<template>
  <div>
    <h2>姓名： {{ name }}</h2>
    <h2>年级: {{ myAge + 1 }}</h2>
    <h2>性别: {{ sex }}</h2>
    <button @click="showName">点我提示学校名</button>
    <button @click="updateAge">尝试修改收到的年龄</button>
  </div>
</template>

<script>
export default {
  name: "Student",
  data() {
    return {
      myAge:this.age
    };
  },
  //简单接受
  // props:['name','age','sex'],

  //对返回的数据做类型检查
  // props: {
  //   name: String,
  //   age: String,
  //   sex: String
  // },

  // 完整的接受父组件穿的信息,默认值想显示
  props: {
    name: {
      type: String,
      require: true,
    },
    age: {
      type: Number,
      require: true,
    },
    sex: {
      type: String,
      require: true,
    },
  },
  methods: {
    showName() {
      alert("点击我" + this.name);
    },
    updateAge(){
				this.myAge++
			}
  },
};
</script>

<style scoped>
</style>